package com.usian.order.controller;

import com.usian.order.fegin.UserFegin;
import com.usian.order.pojo.Order;
import com.usian.order.pojo.User;
import com.usian.order.service.OrderService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @TODO:
 * @Author:baimu
 * @Date:2024 10 24 09 11
 **/

@RestController
@RequestMapping("/order")
@Slf4j
public class OrderController {

    @Autowired
    OrderService orderService;

    @Autowired
    UserFegin userFegin;

    @RequestMapping("/findOrderById")
    public Order findOrderById(Integer id)
    {
        return orderService.findOrderById(id);
    }


    @PostMapping("/saveUser")
    public int saveUser(@RequestBody User user){
        log.info("user:{}",user.toString());
        return userFegin.insertUser(user);
    }




    @GetMapping("/findAll")
    public List<Order> findAll(){

        return orderService.findAll();

    }
}
